package com.hzhr.iot.statis.dao;

import com.hzhr.iot.statis.dao.mapper.custom.DeptMonthlyGasConsumeEntityCustomMapper;
import com.hzhr.iot.statis.dao.mapper.generator.DeptMonthlyGasConsumeEntityMapper;
import com.hzhr.iot.statis.entity.DeptMonthlyGasConsumeEntity;
import com.hzhr.iot.statis.entity.ext.DeptMonthlyGasConsumeEntityExt;
import com.hzhr.iot.statis.queryModel.DeptMonthlyGasConsumeQueryModel;
import com.hzhr.iot.statis.queryModel.custom.DeptMonthlyGasConsumeCustomQueryModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Repository
public class DeptMonthlyGasConsumeDao {
    @Autowired
    DeptMonthlyGasConsumeEntityMapper deptMonthlyGasConsumeEntityMapper;
    @Autowired
    DeptMonthlyGasConsumeEntityCustomMapper deptMonthlyGasConsumeEntityCustomMapper;

    public int insert(DeptMonthlyGasConsumeEntity record) {
        if (record == null) return 0;
        int changeCount = deptMonthlyGasConsumeEntityMapper.insert(record);
        return changeCount;
    }

    public int delete(DeptMonthlyGasConsumeCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int changeCount = deptMonthlyGasConsumeEntityCustomMapper.delete(queryModel);
        return changeCount;
    }

    public int update(DeptMonthlyGasConsumeEntity record) {
        if (record == null) return 0;
        int changeCount = deptMonthlyGasConsumeEntityMapper.updateByPrimaryKey(record);
        return changeCount;
    }

    public int updateProps(DeptMonthlyGasConsumeCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int changeCount = deptMonthlyGasConsumeEntityCustomMapper.updateProps(queryModel);
        return changeCount;
    }

    public DeptMonthlyGasConsumeEntity selectEntity(DeptMonthlyGasConsumeCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<DeptMonthlyGasConsumeEntityExt> extList = deptMonthlyGasConsumeEntityCustomMapper.selectExt(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<DeptMonthlyGasConsumeEntity> selectEntityList(DeptMonthlyGasConsumeCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<DeptMonthlyGasConsumeEntityExt> extList = deptMonthlyGasConsumeEntityCustomMapper.selectExt(queryModel);
        if (extList == null) return null;
        List<DeptMonthlyGasConsumeEntity> entityList = new ArrayList<>();
        for (DeptMonthlyGasConsumeEntityExt ext : extList) {
            entityList.add(ext);
        }
        return entityList;
    }
    public DeptMonthlyGasConsumeEntityExt selectExt(DeptMonthlyGasConsumeCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<DeptMonthlyGasConsumeEntityExt> extList = deptMonthlyGasConsumeEntityCustomMapper.selectExt(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<DeptMonthlyGasConsumeEntityExt> selectExtList(DeptMonthlyGasConsumeCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<DeptMonthlyGasConsumeEntityExt> extList = deptMonthlyGasConsumeEntityCustomMapper.selectExt(queryModel);
        return extList;
    }

    public int selectCount(DeptMonthlyGasConsumeCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int count = deptMonthlyGasConsumeEntityCustomMapper.selectCount(queryModel);
        return count;
    }

    public Double selectDataSum(DeptMonthlyGasConsumeQueryModel queryModel) {
        if (queryModel == null) return 0.0;
        Double dataSum = deptMonthlyGasConsumeEntityCustomMapper.selectDataSum(queryModel);
        dataSum = dataSum == null ? 0.0 : dataSum;
        return dataSum;
    }
}
